package com.google.code.garbagecan.springdatastudy.jpa.example1.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.google.code.garbagecan.springdatastudy.jpa.example1.domain.User;

public interface UserRepository extends JpaRepository<User, Long> {

	User findByTheUserName(String username);

	List<User> findByLastname(String lastname);

	@Query("select u from User u where u.firstname = ?")
	List<User> findByFirstname(String firstname);
	
	@Query("select u from User u where u.firstname = :name or u.lastname = :name")
	List<User> findByFirstnameOrLastname(@Param("name") String name);
}
